import { defineStore } from 'pinia';

export const taskAttr =  defineStore('taskAttr',{
    state:()=>({
        tasks:[],
    }),
    actions:{
        setStateData(value){
            this.tasks=value;
        },
        addTask(task){
            this.tasks.push(task);
        },
        updateTaskByNo(TASK_NODE_NO,updatedProperties){
            const index = this.tasks.findIndex(item => item.TASK_NODE_NO === TASK_NODE_NO); 
            console.log(updatedProperties,"updatedProperties111") 
            console.log(index,"updatedProperties111") 
            if (index !== -1) {  
                Object.assign(this.tasks[index], updatedProperties);  
            }
        },
        removeTask(TASK_NODE_NO){
            const index = this.tasks.findIndex(item => item.TASK_NODE_NO === TASK_NODE_NO);  
            if (index !== -1) {  
                this.tasks.splice(index,1);  
            }
        }
    }
});